<% include ../header %>
        <div class="row-fluid">
        <% if(!operate.success&&operate.msg.length>0) {%>
        <div class="alert alert-danger"><a class="close" data-dismiss="alert" href="#">&times;</a><%= operate.msg%></div>
        <% }%>
        <form class="form-horizontal" method="post" action="">
            <% if(edit){ %>
            <h3>编辑套餐信息</h3>
            <% }else{ %>
            <h3>创建新套餐</h3>
            <% } %>
            <hr/>          

            <div class="form-group">
                <label class="col-md-2 control-label" for="name">套餐:</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" id="name" name="name"
                    <% if(edit){ %>
                    value="<%= editFood.name %>"
                    <% }else{ %>
                    value=""
                    <% } %>> 
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="price">价格:</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" id="price" name="price"
                    <% if(edit){ %>
                    value="<%= editFood.price %>"
                    <% }else{ %>
                    value=""
                    <% } %>> 
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="shopId">商家:</label>
                <div class="col-md-4">
                    <select class="form-control" name="shopId" id="shopId">
                        <% for(var i=0;i<shopes.length;i++){ %>
                            <% if(edit&&shopes[i].id==editFood.shopId){ %>
                                <option value="<%= shopes[i].id%>" selected ><%= shopes[i].name %></option>
                            <% }else{ %>
                                <option value="<%= shopes[i].id%>" ><%= shopes[i].name %></option>
                            <% } %> 
                        <% } %> 
                    </select>
                </div>
            </div>

            
            <div class="form-group">
                <div class="col-md-10 col-md-offset-2">
                    <% if(edit){ %>
                    <input type="submit" value="保存" class="btn btn-primary" id="submit_btn" onclick ="return checkForm();"><% }else{ %>
                    <input type="submit" value="创建" class="btn btn-primary" id="submit_btn" onclick ="return checkForm();"><% } %>
                    <a href="/admin/food" class="btn btn-default">取消</a>
                </div>
            </div>
        </form>
    </div> 
    <script type="text/javascript">
        function checkForm(){
            var name=$('#name').val().trim();
            var price=$('#price').val().trim();
            if(name==""||price==""){
                return false;
            }
            return true;
        }   
    </script>
<% include ../footer %>